package com.wavehi.web;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;

/**
 * @Author WaveHi
 * @Date 16/9/2021 下午 4:25
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description Demonstrate the usr of JSTL.
 */
@WebServlet("/jSTLDemoServlet")
public class JSTLDemoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置域数据
        String judge = "Ok!";
        ArrayList<String> list = new ArrayList<>(16);
        list.add("Wow!");
        list.add("Hello!");
        list.add("Ok!");
        list.add("Yes!");
        req.setAttribute("judge", judge);
        req.setAttribute("num1", Integer.valueOf("20"));
        req.setAttribute("list", list);
        req.setAttribute("date", new Date());
        //获取请求转发对象
        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/page/useJSTL.jsp");
        //请求转发
        requestDispatcher.forward(req, resp);
    }
}
